package com.gs.djys.checkfragments.license;

import android.app.Activity;
import android.content.Context;

import com.alibaba.fastjson.JSON;
import com.gs.djys.Base.Urls;
import com.gs.djys.mvp.BasePresenterImpl;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;
import com.lzy.okgo.model.Response;

import java.util.List;

/**
 * MVPPlugin
 *  邮箱 784787081@qq.com
 */

public class LicensePresenter extends BasePresenterImpl<LicenseContract.View> implements LicenseContract.Presenter{
    @Override
    public void getXKXX(String req_no, String sign, Activity Activity) {
        OkGo.<String>get(Urls.SERVER + "/road/lictran/licApp/request/get")
                .params("req_no", req_no)
                .params("sign", sign)
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(Response<String> response) {
                        LicenseBean landBean = JSON.parseObject(response.body(),LicenseBean.class);
                        if (mView == null)
                            return;
                        if (landBean.getCode().equals("0000")){
                            mView.getXKXXs(landBean);
                        }else {
                            mView.onRequestError(landBean.getMessage());
                        }
                    }
                });
    }
    @Override
    public void getRouter(String req_no) {
        OkGo.<String>get(Urls.SERVER + "/road/lictran/licApp/getLicRoutes")
                .params("req_no", req_no)
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(Response<String> response) {
                        RouterBean routerBean = JSON.parseObject(response.body(),RouterBean.class);
                        if (mView == null)
                            return;
                        if (routerBean.getCode().equals("0000")){
                            mView.getRouters(routerBean);
                        }else {
                            mView.onRequestError(routerBean.getMessage());
                        }
                    }
                });
    }
}
